package com.senken.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.senken.base.BaseController;
import com.senken.entity.Approve;
import com.senken.entity.ApproveVo;
import com.senken.service.IApproveService;
import com.senken.service.ITotalstateService;

@Controller
@RequestMapping("/approve")
public class ApproveController extends BaseController{

	@Autowired
	private IApproveService approveService;
	@Autowired
	private ITotalstateService totalService;
	
	@RequestMapping("/selectBySid")
	@ResponseBody
	public List<ApproveVo> approves(int hid){
		return approveService.approves(hid);
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public Object updateapprove(String device,int opinion,int hid,int sid){
		if(approveService.updateApprove(device, opinion, hid, sid)){
			if(sid==3){
				totalService.updatestate(hid, 4, 2);
			}
			return renderSuccess();
		}
		return renderError("系统异常");
	}
	
	
}
